package com.jz.netthings.engine.sqlite.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jz.netthings.appengine.baseData.ProviderInfo;
import com.jz.netthings.application.providerCollection.bean.*;
import com.jz.netthings.application.providerCollection.mapper.mysql.*;
import com.jz.netthings.application.providerCollection.service.ProviderCollectionService;
import com.jz.netthings.bloodsources.bean.XyReturnVisit;
import com.jz.netthings.bloodsources.mapper.XyReturnVisitMapper;
import com.jz.netthings.engine.sqlite.SqliteDbEngine;
import com.jz.netthings.engine.sqlite.service.GetMachineLogToDataBaseService;
import com.jz.netthings.exception.AdscmSystemException;
import com.jz.netthings.utils.AdscmBaseUtils;
import com.jz.netthings.utils.AdscmDateUtils;
import com.jz.netthings.utils.TextUnit;
import org.apache.ibatis.jdbc.SQL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import sun.security.krb5.internal.rcache.DflCache;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.util.List;

/**
 * @author zyl
 * @Date 2019/4/10 -14:27
 */
@Service
public class GetMachineLogToDataBaseServiceImpl implements GetMachineLogToDataBaseService {
    Logger logger = LoggerFactory.getLogger(GetMachineLogToDataBaseServiceImpl.class);
    @Autowired
    ProviderCollectionMapper providerCollectionMapper;

    @Autowired
    private CollectingPlasmaMapper collectingPlasmaMapper;

    @Autowired
    private ConsumableExceptionMapper consumableExceptionMapper;

    @Autowired
    private DonatorMapper donatorMapper;

    @Autowired
    private DonatorLoginMapper donatorLoginMapper;

    @Autowired
    private InflatingMapper inflatingMapper;

    @Autowired
    private MutualCheckMapper mutualCheckMapper;

    @Autowired
    private ParameterSettingsMapper parameterSettingsMapper;

    @Autowired
    private PoweroffMapper poweroffMapper;

    @Autowired
    private ProvisionConsumableMapper provisionConsumableMapper;

    @Autowired
    private PushButtonMapper pushButtonMapper;

    @Autowired
    private SelfCheckMapper selfCheckMapper;

    @Autowired
    private PrechargeMapper prechargeMapper;


    @Autowired
    CollectingPlasmaEndMapper collectingPlasmaEndMapper;
    @Autowired
    DeviceExceptionMapper deviceExceptionMapper;
    @Autowired
    DonatorExceptionMapper donatorExceptionMapper;
    @Autowired
    HsProcedureMapper hsProcedureMapper;
    @Autowired
    InputResourceMapper inputResourceMapper;
    @Autowired
    NurseMapper nurseMapper;
    @Autowired
    PeriodicMapper periodicMapper;
    @Autowired
    PuncturingMapper puncturingMapper;
    @Autowired
    RegistrationPoweronMapper registrationPoweronMapper;
    @Autowired
    UninstallConsumableMapper uninstallConsumableMapper;
    @Autowired
    ProviderCollectionService providerCollectionService;
    @Autowired
    XyReturnVisitMapper xyReturnVisitMapper;

    @Override
    public void getMachineLogToDataBase(String mlogId, String newFilePath) throws Exception {
        //根据旧地址查询出采浆记录
        if (!AdscmBaseUtils.getInstance().isNotEmpty(mlogId, null)) {
            throw new AdscmSystemException("旧文件名为空");
        }
        if (!AdscmBaseUtils.getInstance().isNotEmpty(newFilePath, null)) {
            throw new AdscmSystemException("新地址为空");
        }
//        String[] path = oldFilePath.split("\\\\");
//        String mlogId = path[path.length - 1];
        Wrapper<ProviderCollection> providerCollectionWrapper = new EntityWrapper<>();
        providerCollectionWrapper.like("machineLogId", mlogId.trim());
//        providerCollectionWrapper.eq("machineLogId",mlogId);
        List<ProviderCollection> providerCollections = providerCollectionMapper.selectList(providerCollectionWrapper);
        if (!(providerCollections != null && providerCollections.size() > 0)) {
            throw new AdscmSystemException("未查询到对应日志信息对应的采浆记录");
        }
        ProviderCollection providerCollection = providerCollections.get(0);

        SqliteDbEngine dbEngine = new SqliteDbEngine(newFilePath);


//       采浆记录-采集环节
        try {
            collecting_plasmaInsert(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录-采集环节", e);
        }
//       采浆记录-耗材异常
        try {
            consumable_exceptionInsert(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录-耗材异常", e);
        }
//       采浆记录-浆员
        try {
            donatorInsert(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录-浆员", e);
        }
//      浆员登录
        try {
            donator_loginInsert(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("浆员登录", e);
        }
//      采浆记录 -加压
        try {
            inflatingInsert(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录 -加压", e);
        }
//      采浆记录-互检
        try {
            mutual_checkInsert(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录-互检", e);
        }
//      采浆记录-设置参数
        try {
            parameter_settingsInsert(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录-设置参数", e);
        }

//      采浆记录-机器关闭
        try {
            poweroffInsert(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录-机器关闭", e);
        }
//      采浆记录-准备耗材
        try {
            provision_consumableInsert(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录-准备耗材", e);
        }
//      采浆记录-按键记录
        try {
            push_buttonInsert(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录-按键记录", e);
        }
//        采浆记录-自检
        try {
            self_checkInsert(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录-自检", e);
        }
//        采浆记录-预充
        try {
            prechargeInsert(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录-预充", e);
        }
        //采集完成
        try {
            collectingPlasmaEnd(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录-采集完成", e);
        }
        //设备异常
        try {
            deviceException(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录-设备异常", e);
        }
        //浆员
        try {
            donatorException(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录-浆员", e);
        }
        //还输
        try {
            HSProcedure(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录-还输", e);
        }
        //输入资源
        try {
            inputResource(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录-输入资源", e);
        }
        //护士
        try {
            nurse(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录-护士", e);
        }
        //周期性数据
        try {
            periodic(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录-周期性数据", e);
        }

        try {
            puncturing(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录-穿刺", e);
        }
        try {
            registrationPoweron(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录-采集环节", e);
        }
        try {
            uninstallConsumable(mlogId, dbEngine, providerCollection);
        } catch (Exception e) {
            logger.error("采浆记录-开关机时间", e);
        }
        dbEngine.freeConn();


        //修改采浆记录
        try {
            updateCollectionInfo(mlogId, dbEngine, providerCollection, newFilePath);
            //同步生成回访记录信息 开启线程
            CreateReturnVisitInfo runnableObj =  new CreateReturnVisitInfo();
            runnableObj.setProviderCollection(providerCollection);
            new Thread(runnableObj).start();
        } catch (Exception e) {
            logger.error("采浆记录-修改采浆总记录", e);
        }
        try {
            providerCollectionService.dealProviderCollection(providerCollection);
            providerCollection.setIsDeal("1");
            providerCollectionMapper.updateById(providerCollection);
        } catch (Exception e) {
            logger.error("更新费用、热合、化检记录异常，请手动操作", e);
        }
    }
    /**
     * 生成回访信息
     */
    class CreateReturnVisitInfo implements  Runnable{
        private ProviderCollection providerCollection;

        public ProviderCollection getProviderCollection() {
            return providerCollection;
        }

        public void setProviderCollection(ProviderCollection providerCollection) {
            this.providerCollection = providerCollection;
        }

        @Override
        public void run() {
            //进行回访数据生成
            saveReturnVisitInfo(providerCollection);
        }
    }

    /**
     * 保存回访信息到表【xy_return_visit】
     * @return
     */
    private Boolean saveReturnVisitInfo(ProviderCollection providerCollection){
        Boolean isSuccess = false;
        if(providerCollection != null && !"".equals(providerCollection)){
            XyReturnVisit xyReturnVisit  =  covertProviderCollectionToXyReturnVisit(providerCollection);
            if(xyReturnVisit!=null && !"".equals(xyReturnVisit)){
                Integer  isOk = xyReturnVisitMapper.insert(xyReturnVisit);
                if(isOk!=0){
                    logger.info("保存回访信息到表【xy_return_visit】 成功，返回值【"+isOk+"】");
                }else{
                    logger.info("保存回访信息到表【xy_return_visit】 失败，返回值【"+isOk+"】");
                }
            }
        }else{
            logger.info("保存回访信息到表【xy_return_visit】时，【providerCollection】值为null，请查明数据丢失原因....");
        }
        return  isSuccess;
    }

    /**
     * 进行转换
     * @param providerCollection
     * @return
     */
    private XyReturnVisit covertProviderCollectionToXyReturnVisit(ProviderCollection providerCollection){
        XyReturnVisit xyReturnVisit  =   new XyReturnVisit();
        xyReturnVisit.setProviderId(Long.valueOf(providerCollection.getProviderNo()));
        xyReturnVisit.setProviderName(providerCollection.getProviderName());
        xyReturnVisit.setCardId(providerCollection.getCardId());
        xyReturnVisit.setNurseId(Long.parseLong(providerCollection.getNurse()));
        xyReturnVisit.setNurseName(providerCollection.getNurseName());
        xyReturnVisit.setCreateTime(new Date());
        xyReturnVisit.setCommunicateState("2");
        xyReturnVisit.setCommunicateType("1");
        return xyReturnVisit;
    };
    /**
     * 更新采浆记录
     *
     * @param mlogId
     * @param dbEngine
     * @param providerCollection
     * @param newFilePath
     * @throws Exception
     */
    private void updateCollectionInfo(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection, String newFilePath) throws Exception {
        providerCollection.setFilePath(newFilePath);
        providerCollection.setSynDate(AdscmDateUtils.getFormateDate(new Date()));
        providerCollection.setModifyTime(new Date());
        providerCollection.setLogTime(new Date());
        providerCollectionMapper.updateById(providerCollection);
    }

    /**
     * 卸载耗材
     *
     * @param mlogId
     * @param dbEngine
     */
    private void uninstallConsumable(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws Exception {
        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM uninstall_consumable");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {
            UninstallConsumable uninstallConsumable = uninstallConsumableMapper.selectById(mlogId);
            boolean isUpdate = false;
            if (AdscmBaseUtils.getInstance().isNotEmpty(uninstallConsumable, null)) {
                isUpdate = true;
            } else {
                uninstallConsumable = new UninstallConsumable();
            }
            String uninstall_start = rs.getString("uninstall_start");
            String uninstall_plasma_bag = rs.getString("uninstall_plasma_bag");
            String open_lxj_switch = rs.getString("open_lxj_switch");
            String uninstall_DPM = rs.getString("uninstall_DPM");
            String uninstall_end = rs.getString("uninstall_end");
            logger.info("uninstall_start" + uninstall_start);
            logger.info("uninstall_plasma_bag" + uninstall_plasma_bag);
            logger.info("open_lxj_switch" + open_lxj_switch);
            logger.info("uninstall_DPM" + uninstall_DPM);
            logger.info("uninstall_end" + uninstall_end);

            uninstallConsumable.setMlogId(mlogId);
            uninstallConsumable.setUninstallStart(new Date(Long.valueOf(uninstall_start)));
            uninstallConsumable.setUninstallPlasmaBag(new Date(Long.valueOf(uninstall_plasma_bag)));
            uninstallConsumable.setOpenLxjSwitch(new Date(Long.valueOf(open_lxj_switch)));
            uninstallConsumable.setUninstallDpm(new Date(Long.valueOf(uninstall_DPM)));
            uninstallConsumable.setUninstallEnd(new Date(Long.valueOf(uninstall_end)));

            providerCollection.setUninstallStartTime(uninstallConsumable.getUninstallStart());
            providerCollection.setUninstallEndTime(uninstallConsumable.getUninstallEnd());
            try {
                providerCollection.setUninstallTaken(providerCollection.getUninstallEndTime().getTime() - providerCollection.getUninstallStartTime().getTime());
            } catch (Exception e) {
            }

            if (isUpdate) {
                uninstallConsumableMapper.updateById(uninstallConsumable);
            } else {
                uninstallConsumableMapper.insert(uninstallConsumable);
            }


        }
    }

    /**
     * 开关机时间
     *
     * @param mlogId
     * @param dbEngine
     */
    private void registrationPoweron(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws Exception {
        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM registration_poweron");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {
            RegistrationPoweron registrationPoweron = registrationPoweronMapper.selectById(mlogId);
            boolean isUpdate = false;
            if (AdscmBaseUtils.getInstance().isNotEmpty(registrationPoweron, null)) {
                isUpdate = true;
            } else {
                registrationPoweron = new RegistrationPoweron();
            }

            String ap_code = rs.getString("ap_code");
            String poweron_time = rs.getString("poweron_time");
            String device_register_time = rs.getString("device_register_time");
            String nurse_registration_time = rs.getString("nurse_registration_time");
            String nurse_logout_time = rs.getString("nurse_logout_time");
            String daily_log_filename = rs.getString("daily_log_filename");
            logger.info("ap_code" + ap_code);
            logger.info("poweron_time" + poweron_time);
            logger.info("device_register_time" + device_register_time);
            logger.info("nurse_registration_time" + nurse_registration_time);
            logger.info("nurse_logout_time" + nurse_logout_time);
            logger.info("daily_log_filename" + daily_log_filename);


            registrationPoweron.setMlogId(mlogId);
            registrationPoweron.setApCode(ap_code);
            registrationPoweron.setPoweronTime(new Date(Long.valueOf(poweron_time)));
            registrationPoweron.setDeviceRegisterTime(new Date(Long.valueOf(device_register_time)));
            registrationPoweron.setNurseRegistrationTime(new Date(Long.valueOf(nurse_registration_time)));
            registrationPoweron.setNurseLogoutTime(new Date(Long.valueOf(nurse_logout_time)));
            registrationPoweron.setDailyLogFilename(daily_log_filename);

            if (isUpdate) {
                registrationPoweronMapper.updateById(registrationPoweron);
            } else {
                registrationPoweronMapper.insert(registrationPoweron);
            }


        }
    }

    /**
     * 穿刺
     *
     * @param mlogId
     * @param dbEngine
     */
    private void puncturing(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws Exception {
        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM puncturing");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {
            Puncturing puncturing = puncturingMapper.selectById(mlogId);
            boolean isUpdate = false;
            if (AdscmBaseUtils.getInstance().isNotEmpty(puncturing, null)) {
                isUpdate = true;
            } else {
                puncturing = new Puncturing();
            }

            String start_puncturing_time = rs.getString("start_puncturing_time");
            logger.info("start_puncturing_time" + start_puncturing_time);

            puncturing.setMlogId(mlogId);
            puncturing.setStartPuncturingTime(new Date(Long.valueOf(start_puncturing_time)));

            providerCollection.setPunctureStartTime(puncturing.getStartPuncturingTime());
            try {
                providerCollection.setPunctureTaken(providerCollection.getPunctureEndTime().getTime() - providerCollection.getPunctureStartTime().getTime());
            } catch (Exception e) {
            }
            if (isUpdate) {
                puncturingMapper.updateById(puncturing);
            } else {
                puncturingMapper.insert(puncturing);
            }


        }
    }

    /**
     * 周期性
     *
     * @param mlogId
     * @param dbEngine
     */
    private void periodic(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws Exception {
        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM periodic");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {

            String no = rs.getString("no");
            String events = rs.getString("events");
            String time = rs.getString("time");
            String xb_speed = rs.getString("xb_speed");
            String knj_speed = rs.getString("knj_speed");
            String xb_rotated = rs.getString("xb_rotated");
            String knj_rotated = rs.getString("knj_rotated");
            String gy_value = rs.getString("gy_value");
            String xy_value = rs.getString("xy_value");
            String lxj_speed = rs.getString("lxj_speed");
            String xjdzc_weight = rs.getString("xjdzc_weight");
            String knjdzc_weight = rs.getString("knjdzc_weight");
            String ht_value = rs.getString("ht_value");
            String knjb = rs.getString("knjb");
            String cur_xb_draw_rotated = rs.getString("cur_xb_draw_rotated");
            String cur_xb_return_rotated = rs.getString("cur_xb_return_rotated");
            logger.info("no" + no);
            logger.info("events" + events);
            logger.info("time" + time);
            logger.info("xb_speed" + xb_speed);
            logger.info("knj_speed" + knj_speed);
            logger.info("xb_rotated" + xb_rotated);
            logger.info("knj_rotated" + knj_rotated);
            logger.info("gy_value" + gy_value);
            logger.info("xy_value" + xy_value);
            logger.info("lxj_speed" + lxj_speed);
            logger.info("xjdzc_weight" + xjdzc_weight);
            logger.info("knjdzc_weight" + knjdzc_weight);
            logger.info("ht_value" + ht_value);
            logger.info("knjb" + knjb);
            logger.info("cur_xb_draw_rotated" + cur_xb_draw_rotated);
            logger.info("cur_xb_return_rotated" + cur_xb_return_rotated);
            Periodic periodic = new Periodic();
            periodic.setMlogid(mlogId);
            periodic.setNo(Integer.valueOf(no));
            periodic.setEvents(events);
            periodic.setTime(new Date(Long.valueOf(time)));
            periodic.setXbSpeed(Integer.valueOf(xb_speed));
            periodic.setKnjSpeed(Float.valueOf(knj_speed));
            periodic.setXbRotated(Float.valueOf(xb_rotated));
            periodic.setKnjRotated(Float.valueOf(knj_rotated));
            periodic.setGyValue(Float.valueOf(gy_value));
            periodic.setXyValue(Integer.valueOf(xy_value));
            periodic.setLxjSpeed(Integer.valueOf(lxj_speed));
            periodic.setXjdzcWeight(Integer.valueOf(xjdzc_weight));
            periodic.setKnjdzcWeight(Float.valueOf(knjdzc_weight));
            periodic.setHtValue(Integer.valueOf(ht_value));
            periodic.setKnjb(Float.valueOf(knjb));
            periodic.setCurXbDrawRotated(Float.valueOf(cur_xb_draw_rotated));
            periodic.setCurXbReturnRotated(Float.valueOf(cur_xb_return_rotated));
            Wrapper<Periodic> wrapper = new EntityWrapper<>();
            wrapper.eq("mlogId", periodic.getMlogid());
            wrapper.eq("no", periodic.getNo());
            List<Periodic> periodics = periodicMapper.selectList(wrapper);
            if (periodics != null && periodics.size() > 0) {
                periodicMapper.update(periodic, wrapper);
            } else {
                periodicMapper.insert(periodic);
            }
        }
    }

    /**
     * 护士信息
     *
     * @param mlogId
     * @param dbEngine
     */
    private void nurse(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws Exception {
        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM nurse");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {
            Nurse nurse = nurseMapper.selectById(mlogId);
            boolean isupdate = false;
            if (AdscmBaseUtils.getInstance().isNotEmpty(nurse, null)) {
                isupdate = true;
            } else {
                nurse = new Nurse();
            }

            String name = rs.getString("name");
            String id = rs.getString("id");
            String sex = rs.getString("sex");
            String age = rs.getString("age");
            String address = rs.getString("address");
            String photo_path = rs.getString("photo_path");

            logger.info("name" + name);
            logger.info("id" + id);
            logger.info("sex" + sex);
            logger.info("age" + age);
            logger.info("address" + address);
            logger.info("photo_path" + photo_path);

            if (!AdscmBaseUtils.getInstance().isNotEmpty(providerCollection.getNurse(),null)){
                providerCollection.setNurse(id);
            }

            nurse.setMlogId(mlogId);
            nurse.setName(name);
            nurse.setId(id);
            nurse.setSex(sex);
            nurse.setAge(Integer.valueOf(age));
            nurse.setAddress(address);
            nurse.setPhotoPath(photo_path);
            if (isupdate) {
                nurseMapper.updateById(nurse);
            } else {
                nurseMapper.insert(nurse);
            }
        }

    }

    /**
     * 输入资源
     *
     * @param mlogId
     * @param dbEngine
     */
    private void inputResource(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws Exception {
        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM input_resource");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {
            InputResource inputResource = inputResourceMapper.selectById(mlogId);
            boolean isUpdate = false;
            if (AdscmBaseUtils.getInstance().isNotEmpty(inputResource, null)) {
                isUpdate = true;
            } else {
                inputResource = new InputResource();
                inputResource.setMlogId(mlogId);
            }

            String device_ID = rs.getString("device_ID");
            String time_device_ID_read = rs.getString("time_device_ID_read");
            String nurse_ID = rs.getString("nurse_ID");
            String time_nurse_ID_read = rs.getString("time_nurse_ID_read");
            String donator_ID = rs.getString("donator_ID");
            String time_donator_ID_read = rs.getString("time_donator_ID_read");
            String FPS_vendor = rs.getString("FPS_vendor");
            String time_FPS_vendor_read = rs.getString("time_FPS_vendor_read");
            String FPS_BNO = rs.getString("FPS_BNO");
            String time_FPS_BNO_read = rs.getString("time_FPS_BNO_read");
            String ACD_vendor = rs.getString("ACD_vendor");
            String time_ACD_vendor_read = rs.getString("time_ACD_vendor_read");
            String ACD_BNO = rs.getString("ACD_BNO");
            String time_ACD_BNO_read = rs.getString("time_ACD_BNO_read");
            String saline_vendor = rs.getString("saline_vendor");
            String time_saline_vendor = rs.getString("time_saline_vendor");
            String saline_BNO = rs.getString("saline_BNO");
            String time_saline_BNO_read = rs.getString("time_saline_BNO_read");
            logger.info("device_ID" + device_ID);
            logger.info("time_device_ID_read" + time_device_ID_read);
            logger.info("nurse_ID" + nurse_ID);
            logger.info("time_nurse_ID_read" + time_nurse_ID_read);
            logger.info("donator_ID" + donator_ID);
            logger.info("time_donator_ID_read" + time_donator_ID_read);
            logger.info("FPS_vendor" + FPS_vendor);
            logger.info("time_FPS_vendor_read" + time_FPS_vendor_read);
            logger.info("FPS_BNO" + FPS_BNO);
            logger.info("time_FPS_BNO_read" + time_FPS_BNO_read);
            logger.info("ACD_vendor" + ACD_vendor);
            logger.info("time_ACD_vendor_read" + time_ACD_vendor_read);
            logger.info("ACD_BNO" + ACD_BNO);
            logger.info("time_ACD_BNO_read" + time_ACD_BNO_read);
            logger.info("saline_vendor" + saline_vendor);
            logger.info("time_saline_vendor" + time_saline_vendor);
            logger.info("saline_BNO" + saline_BNO);
            logger.info("time_saline_BNO_read" + time_saline_BNO_read);
//            inputResource.setMlogId(device_ID);
            inputResource.setDeviceId(device_ID);
            inputResource.setTimeDeviceIdRead(new Date(Long.valueOf(time_device_ID_read)));
            inputResource.setNurseId(nurse_ID);
            inputResource.setTimeNurseIdRead(new Date(Long.valueOf(time_nurse_ID_read)));
            inputResource.setDonatorId(donator_ID);
            inputResource.setTimeDonatorIdRead(new Date(Long.valueOf(time_donator_ID_read)));
            inputResource.setFpsBno(FPS_vendor);
            inputResource.setTimeFpsVendorRead(new Date(Long.valueOf(time_FPS_vendor_read)));
            inputResource.setFpsBno(FPS_BNO);
            inputResource.setTimeFpsBnoRead(new Date(Long.valueOf(time_FPS_BNO_read)));
            inputResource.setAcdVendor(ACD_vendor);
            inputResource.setTimeAcdVendorRead(new Date(Long.valueOf(time_ACD_vendor_read)));
            inputResource.setAcdBno(ACD_BNO);
            inputResource.setTimeAcdBnoRead(new Date(Long.valueOf(time_ACD_BNO_read)));
            inputResource.setSalineVendor(saline_vendor);
            inputResource.setTimeSalineVendor(new Date(Long.valueOf(time_saline_vendor)));
            inputResource.setSalineBno(saline_BNO);
            inputResource.setTimeSalineBnoRead(new Date(Long.valueOf(time_saline_BNO_read)));


            try {
                String batchno = "";
                batchno += TextUnit.ObjToString(inputResource.getFpsBno());
                batchno += ",";
                batchno += TextUnit.ObjToString(inputResource.getAcdBno());
                batchno += ",";
                batchno += TextUnit.ObjToString(inputResource.getSalineBno());

                providerCollection.setHcBatchNo(batchno);
            } catch (Exception e) {
            }

            if (isUpdate) {
                inputResourceMapper.updateById(inputResource);
            } else {
                inputResourceMapper.insert(inputResource);
            }


        }
    }

    /**
     * 还输
     *
     * @param mlogId
     * @param dbEngine
     */
    private void HSProcedure(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws Exception {
        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM HS_procedure");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {
            String floor = rs.getString("floor");
            String HS_start_time = rs.getString("HS_start_time");
            String HS_quantity = rs.getString("HS_quantity");
            String time_HS_quantity = rs.getString("time_HS_quantity");
            String turns_XB_rotated_HS = rs.getString("turns_XB_rotated_HS");
            String time_turns_XB_rotated_HS = rs.getString("time_turns_XB_rotated_HS");
            String plasma_valve_open_time = rs.getString("plasma_valve_open_time");
            String turns_XB_rotated_PVOT = rs.getString("turns_XB_rotated_PVOT");
            String time_turns_XB_rotated_PVOT = rs.getString("time_turns_XB_rotated_PVOT");
            String saline_valve_open_time = rs.getString("saline_valve_open_time");
            String saline_valve_close_time = rs.getString("saline_valve_close_time");
            String turns_XB_rotated_HS_XYKT0_detect_air = rs.getString("turns_XB_rotated_HS_XYKT0_detect_air");
            String time_turns_XB_rotated_HS_XYKT0_detect_air = rs.getString("time_turns_XB_rotated_HS_XYKT0_detect_air");
            String XYKT0_HS_detect_air_time = rs.getString("XYKT0_HS_detect_air_time");
            String HS_end_time = rs.getString("HS_end_time");
            String HS_end_time_XYKT0_detect_air = rs.getString("HS_end_time_XYKT0_detect_air");
            String HS_end_time_XYKT2_detect_air = rs.getString("HS_end_time_XYKT2_detect_air");
            logger.info("floor" + floor);
            logger.info("HS_start_time" + HS_start_time);
            logger.info("HS_quantity" + HS_quantity);
            logger.info("time_HS_quantity" + time_HS_quantity);
            logger.info("turns_XB_rotated_HS" + turns_XB_rotated_HS);
            logger.info("time_turns_XB_rotated_HS" + time_turns_XB_rotated_HS);
            logger.info("plasma_valve_open_time" + plasma_valve_open_time);
            logger.info("turns_XB_rotated_PVOT" + turns_XB_rotated_PVOT);
            logger.info("time_turns_XB_rotated_PVOT" + time_turns_XB_rotated_PVOT);
            logger.info("saline_valve_open_time" + saline_valve_open_time);
            logger.info("saline_valve_close_time" + saline_valve_close_time);
            logger.info("turns_XB_rotated_HS_XYKT0_detect_air" + turns_XB_rotated_HS_XYKT0_detect_air);
            logger.info("time_turns_XB_rotated_HS_XYKT0_detect_air" + time_turns_XB_rotated_HS_XYKT0_detect_air);
            logger.info("XYKT0_HS_detect_air_time" + XYKT0_HS_detect_air_time);
            logger.info("HS_end_time" + HS_end_time);
            logger.info("HS_end_time_XYKT0_detect_air" + HS_end_time_XYKT0_detect_air);
            logger.info("HS_end_time_XYKT2_detect_air" + HS_end_time_XYKT2_detect_air);
            HsProcedure hsProcedure = new HsProcedure();
            hsProcedure.setMlogId(mlogId);
            hsProcedure.setFloor(Integer.valueOf(floor));
            hsProcedure.setHsStartTime(new Date(Long.valueOf(HS_start_time)));
            hsProcedure.setHsQuantity(Integer.valueOf(HS_quantity));
            hsProcedure.setTimeHsQuantity(new Date(Long.valueOf(time_HS_quantity)));
            hsProcedure.setTurnsXbRotatedHs(Float.valueOf(turns_XB_rotated_HS));
            hsProcedure.setTimeTurnsXbRotatedHs(new Date(Long.valueOf(time_turns_XB_rotated_HS)));
            hsProcedure.setPlasmaValveOpenTime(new Date(Long.valueOf(plasma_valve_open_time)));
            hsProcedure.setTurnsXbRotatedPvot(Float.valueOf(turns_XB_rotated_PVOT));
            if (time_turns_XB_rotated_PVOT != null && !"".equals(time_turns_XB_rotated_PVOT)) {
                hsProcedure.setTimeTurnsXbRotatedPvot(new Date(Long.valueOf(time_turns_XB_rotated_PVOT)));
            }
            hsProcedure.setSalineValveOpenTime(new Date(Long.valueOf(saline_valve_open_time)));
            hsProcedure.setSalineValveCloseTime(new Date(Long.valueOf(saline_valve_close_time)));
            hsProcedure.setTurnsXbRotatedHsXykt0DetectAir(Float.valueOf(turns_XB_rotated_HS_XYKT0_detect_air));
            hsProcedure.setTimeTurnsXbRotatedHsXykt0DetectAir(new Date(Long.valueOf(time_turns_XB_rotated_HS_XYKT0_detect_air)));
            hsProcedure.setXykt0HsDetectAirTime(new Date(Long.valueOf(XYKT0_HS_detect_air_time)));
            hsProcedure.setHsEndTime(new Date(Long.valueOf(HS_end_time)));
            hsProcedure.setHsEndTimeXykt0DetectAir(new Date(Long.valueOf(HS_end_time_XYKT0_detect_air)));
            hsProcedure.setHsEndTimeXykt2DetectAir(new Date(Long.valueOf(HS_end_time_XYKT2_detect_air)));
            Wrapper<HsProcedure> wrapper = new EntityWrapper<>();
            wrapper.eq("mlogId", hsProcedure.getMlogId());
            wrapper.eq("floor", hsProcedure.getFloor());
            List<HsProcedure> hsProcedures = hsProcedureMapper.selectList(wrapper);
            if (hsProcedures != null && hsProcedures.size() > 0) {
                hsProcedureMapper.update(hsProcedure, wrapper);
            } else {
                hsProcedureMapper.insert(hsProcedure);
            }

        }
    }

    /**
     * 浆员异常
     *
     * @param mlogId
     * @param dbEngine
     */
    private void donatorException(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws Exception {
        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM donator_exception");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {


            String no = rs.getString("no");
            String floor = rs.getString("floor");
            String ext_para = rs.getString("ext_para");
            String ext_time = rs.getString("ext_time");
            String ext_recover_time = rs.getString("ext_recover_time");
            String type = rs.getString("type");
            String clinical_reaction = rs.getString("clinical_reaction");
            String ext_level = rs.getString("ext_level");
            logger.info("no" + no);
            logger.info("floor" + floor);
            logger.info("ext_para" + ext_para);
            logger.info("ext_time" + ext_time);
            logger.info("ext_recover_time" + ext_recover_time);
            logger.info("type" + type);
            logger.info("clinical_reaction" + clinical_reaction);
            logger.info("ext_level" + ext_level);
            DonatorException donatorException = new DonatorException();
            donatorException.setMlogId(mlogId);
            donatorException.setNo(Integer.valueOf(no));
            donatorException.setFloor(Integer.valueOf(floor));
            donatorException.setExtPara(Integer.valueOf(ext_para));
            donatorException.setExtTime(new Date(Long.valueOf(ext_time)));
            donatorException.setExtRecoverTime(new Date(Long.valueOf(ext_recover_time)));
            donatorException.setType(Integer.valueOf(type));
            donatorException.setClinicalReaction(clinical_reaction);
            donatorException.setExtLevel(Integer.valueOf(ext_level));
            Wrapper<DonatorException> wrapper = new EntityWrapper<>();
            wrapper.eq("mlogId", donatorException.getMlogId());
            wrapper.eq("no", donatorException.getNo());
            List<DonatorException> donatorExceptions = donatorExceptionMapper.selectList(wrapper);
            if (donatorExceptions != null && donatorExceptions.size() > 0) {
                donatorExceptionMapper.update(donatorException, wrapper);
            } else {
                donatorExceptionMapper.insert(donatorException);
            }


        }
    }

    /**
     * 设备异常
     *
     * @param mlogId
     * @param dbEngine
     */
    private void deviceException(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws Exception {
        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM device_exception");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {
            String no = rs.getString("no");
            String floor = rs.getString("floor");
            String ext_para = rs.getString("ext_para");
            String ext_time = rs.getString("ext_time");
            String ext_recover_time = rs.getString("ext_recover_time");
            String dev_code = rs.getString("dev_code");
            String ext_type = rs.getString("ext_type");
            String ext_msg = rs.getString("ext_msg");
            String ext_level = rs.getString("ext_level");
            logger.info("no" + no);
            logger.info("floor" + floor);
            logger.info("ext_para" + ext_para);
            logger.info("ext_time" + ext_time);
            logger.info("ext_recover_time" + ext_recover_time);
            logger.info("dev_code" + dev_code);
            logger.info("ext_type" + ext_type);
            logger.info("ext_msg" + ext_msg);
            logger.info("ext_level" + ext_level);
            DeviceException deviceException = new DeviceException();
            deviceException.setMlogId(mlogId);
            deviceException.setNo(Integer.valueOf(no));
            deviceException.setFloor(Integer.valueOf(floor));
            deviceException.setExtPara(Integer.valueOf(ext_para));
            deviceException.setExtTime(new Date(Long.valueOf(ext_time)));
            deviceException.setExtRecoverTime(new Date(Long.valueOf(ext_recover_time)));
            deviceException.setDevCode(Integer.valueOf(dev_code));
            deviceException.setExtType(Integer.valueOf(ext_type));
            deviceException.setExtMsg(ext_msg);
            deviceException.setExtLevel(Integer.valueOf(ext_level));
            Wrapper<DeviceException> wrapper = new EntityWrapper<>();
            wrapper.eq("mlogId", deviceException.getMlogId());
            wrapper.eq("no", deviceException.getNo());
            List<DeviceException> deviceExceptions = deviceExceptionMapper.selectList(wrapper);
            if (deviceExceptions != null && deviceExceptions.size() > 0) {
                deviceExceptionMapper.update(deviceException, wrapper);
            } else {
                deviceExceptionMapper.insert(deviceException);
            }

        }
    }

    /**
     * 采浆结束
     *
     * @param mlogId
     * @param dbEngine
     * @throws Exception
     */
    public void collectingPlasmaEnd(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws Exception {

        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM collecting_plasma_end");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {
            CollectingPlasmaEnd collectingPlasmaEnd = collectingPlasmaEndMapper.selectById(mlogId);
            boolean isUpdate = false;

            if (collectingPlasmaEnd != null) {
                isUpdate = true;
            } else {
                collectingPlasmaEnd = new CollectingPlasmaEnd();
            }
            String cycle_time = rs.getString("cycle_time");
            String time_cycle_time = rs.getString("time_cycle_time");
            String collecting_plasma_start_time = rs.getString("collecting_plasma_start_time");
            String collecting_plasma_end_time = rs.getString("collecting_plasma_end_time");
            String collecting_procedure_elapsed_time = rs.getString("collecting_procedure_elapsed_time");
            String time_collecting_procedure_elapsed_time = rs.getString("time_collecting_procedure_elapsed_time");
            String KNJ_initial_weight = rs.getString("KNJ_initial_weight");
            String time_KNJ_initial_weight = rs.getString("time_KNJ_initial_weight");
            String KNJ_precharge_consumed_weight = rs.getString("KNJ_precharge_consumed_weight");
            String time_KNJ_precharge_consumed_weight = rs.getString("time_KNJ_precharge_consumed_weight");
            String KNJ_remaining_weight = rs.getString("KNJ_remaining_weight");
            String time_KNJ_remaining_weight = rs.getString("time_KNJ_remaining_weight");
            String plasma_weight = rs.getString("plasma_weight");
            if (plasma_weight.indexOf(".") > 0) {
                plasma_weight = plasma_weight.substring(0, plasma_weight.indexOf("."));
            }
            String time_plasma_weight = rs.getString("time_plasma_weight");
            String KNJ_plasma_used_weight = rs.getString("KNJ_plasma_used_weight");
            String time_KNJ_plasma_used_weight = rs.getString("time_KNJ_plasma_used_weight");
            String XY_valve_openclose_times = rs.getString("XY_valve_openclose_times");
            String time_XY_valve_openclose_times = rs.getString("time_XY_valve_openclose_times");
            String XJ_valve_openclose_times = rs.getString("XJ_valve_openclose_times");
            String time_XJ_valve_openclose_times = rs.getString("time_XJ_valve_openclose_times");
            String saline_valve_openclose_times = rs.getString("saline_valve_openclose_times");
            String time_saline_valve_openclose_times = rs.getString("time_saline_valve_openclose_times");
            String total_turns_rotated_KNJB = rs.getString("total_turns_rotated_KNJB");
            String time_total_turns_rotated_KNJB = rs.getString("time_total_turns_rotated_KNJB");
            String total_turns_rotated_XB = rs.getString("total_turns_rotated_XB");
            String time_total_turns_rotated_XB = rs.getString("time_total_turns_rotated_XB");
            String KNJKT_state_switching_times = rs.getString("KNJKT_state_switching_times");
            String time_KNJKT_state_switching_times = rs.getString("time_KNJKT_state_switching_times");
            String HT_state_switching_times = rs.getString("HT_state_switching_times");
            String time_HT_state_switching_times = rs.getString("time_HT_state_switching_times");
            String XYKT0_state_switching_times = rs.getString("XYKT0_state_switching_times");
            String time_XYKT0_state_switching_times = rs.getString("time_XYKT0_state_switching_times");
            String XYKT1_state_switching_times = rs.getString("XYKT1_state_switching_times");
            String time_XYKT1_state_switching_times = rs.getString("time_XYKT1_state_switching_times");
            String XYKT2_state_switching_times = rs.getString("XYKT2_state_switching_times");
            String time_XYKT2_state_switching_times = rs.getString("time_XYKT2_state_switching_times");
            String saline_used = rs.getString("saline_used");
            String time_saline_used = rs.getString("time_saline_used");
            logger.info("cycle_time                              :" + cycle_time);
            logger.info("time_cycle_time                         :" + time_cycle_time);
            logger.info("collecting_plasma_start_time            :" + collecting_plasma_start_time);
            logger.info("collecting_plasma_end_time              :" + collecting_plasma_end_time);
            logger.info("collecting_procedure_elapsed_time       :" + collecting_procedure_elapsed_time);
            logger.info("time_collecting_procedure_elapsed_time  :" + time_collecting_procedure_elapsed_time);
            logger.info("KNJ_initial_weight                      :" + KNJ_initial_weight);
            logger.info("time_KNJ_initial_weight                 :" + time_KNJ_initial_weight);
            logger.info("KNJ_precharge_consumed_weight           :" + KNJ_precharge_consumed_weight);
            logger.info("time_KNJ_precharge_consumed_weight      :" + time_KNJ_precharge_consumed_weight);
            logger.info("KNJ_remaining_weight                    :" + KNJ_remaining_weight);
            logger.info("time_KNJ_remaining_weight               :" + time_KNJ_remaining_weight);
            logger.info("plasma_weight                           :" + plasma_weight);
            logger.info("time_plasma_weight                      :" + time_plasma_weight);
            logger.info("KNJ_plasma_used_weight                  :" + KNJ_plasma_used_weight);
            logger.info("time_KNJ_plasma_used_weight             :" + time_KNJ_plasma_used_weight);
            logger.info("XY_valve_openclose_times                :" + XY_valve_openclose_times);
            logger.info("time_XY_valve_openclose_times           :" + time_XY_valve_openclose_times);
            logger.info("XJ_valve_openclose_times                :" + XJ_valve_openclose_times);
            logger.info("time_XJ_valve_openclose_times           :" + time_XJ_valve_openclose_times);
            logger.info("saline_valve_openclose_times            :" + saline_valve_openclose_times);
            logger.info("time_saline_valve_openclose_times       :" + time_saline_valve_openclose_times);
            logger.info("total_turns_rotated_KNJB                :" + total_turns_rotated_KNJB);
            logger.info("time_total_turns_rotated_KNJB           :" + time_total_turns_rotated_KNJB);
            logger.info("total_turns_rotated_XB                  :" + total_turns_rotated_XB);
            logger.info("time_total_turns_rotated_XB             :" + time_total_turns_rotated_XB);
            logger.info("KNJKT_state_switching_times             :" + KNJKT_state_switching_times);
            logger.info("time_KNJKT_state_switching_times        :" + time_KNJKT_state_switching_times);
            logger.info("HT_state_switching_times                :" + HT_state_switching_times);
            logger.info("time_HT_state_switching_times           :" + time_HT_state_switching_times);
            logger.info("XYKT0_state_switching_times             :" + XYKT0_state_switching_times);
            logger.info("time_XYKT0_state_switching_times        :" + time_XYKT0_state_switching_times);
            logger.info("XYKT1_state_switching_times             :" + XYKT1_state_switching_times);
            logger.info("time_XYKT1_state_switching_times        :" + time_XYKT1_state_switching_times);
            logger.info("XYKT2_state_switching_times             :" + XYKT2_state_switching_times);
            logger.info("time_XYKT2_state_switching_times        :" + time_XYKT2_state_switching_times);
            logger.info("saline_used                             :" + saline_used);
            logger.info("time_saline_used                        :" + time_saline_used);

            collectingPlasmaEnd.setMlogId(mlogId);
            collectingPlasmaEnd.setCycleTime(Integer.valueOf(cycle_time));
            collectingPlasmaEnd.setTimeCycleTime(new Date(Long.valueOf(time_cycle_time)));
            collectingPlasmaEnd.setCollectingPlasmaStartTime(new Date(Long.valueOf(collecting_plasma_start_time)));
            collectingPlasmaEnd.setCollectingPlasmaEndTime(new Date(Long.valueOf(collecting_plasma_end_time)));
            collectingPlasmaEnd.setCollectingProcedureElapsedTime(Integer.valueOf(collecting_procedure_elapsed_time));
            collectingPlasmaEnd.setTimeCollectingProcedureElapsedTime(new Date(Long.valueOf(time_collecting_procedure_elapsed_time)));
            collectingPlasmaEnd.setKnjInitialWeight(Float.valueOf(KNJ_initial_weight));
            collectingPlasmaEnd.setTimeKnjInitialWeight(new Date(Long.valueOf(time_KNJ_initial_weight)));
            collectingPlasmaEnd.setKnjPrechargeConsumedWeight(Float.valueOf(KNJ_precharge_consumed_weight));
            collectingPlasmaEnd.setTimeKnjPrechargeConsumedWeight(new Date(Long.valueOf(time_KNJ_precharge_consumed_weight)));
            collectingPlasmaEnd.setKnjRemainingWeight(Float.valueOf(KNJ_remaining_weight));
            collectingPlasmaEnd.setTimeKnjRemainingWeight(new Date(Long.valueOf(time_KNJ_remaining_weight)));
            collectingPlasmaEnd.setPlasmaWeight(Integer.valueOf(plasma_weight));
            collectingPlasmaEnd.setTimePlasmaWeight(new Date(Long.valueOf(time_plasma_weight)));
            collectingPlasmaEnd.setKnjPlasmaUsedWeight(Float.valueOf(KNJ_plasma_used_weight));
            collectingPlasmaEnd.setTimeKnjPlasmaUsedWeight(new Date(Long.valueOf(time_KNJ_plasma_used_weight)));
            collectingPlasmaEnd.setXyValveOpencloseTimes(Integer.valueOf(XY_valve_openclose_times));
            collectingPlasmaEnd.setTimeXyValveOpencloseTimes(new Date(Long.valueOf(time_XY_valve_openclose_times)));
            collectingPlasmaEnd.setSalineValveOpencloseTimes(Integer.valueOf(saline_valve_openclose_times));
            collectingPlasmaEnd.setTimeSalineValveOpencloseTimes(new Date(Long.valueOf(time_saline_valve_openclose_times)));
            collectingPlasmaEnd.setTotalTurnsRotatedKnjb(Float.valueOf(total_turns_rotated_KNJB));
            collectingPlasmaEnd.setTimeTotalTurnsRotatedKnjb(new Date(Long.valueOf(time_total_turns_rotated_KNJB)));
            collectingPlasmaEnd.setTotalTurnsRotatedXb(Float.valueOf(total_turns_rotated_XB));
            collectingPlasmaEnd.setTimeTotalTurnsRotatedXb(new Date(Long.valueOf(time_total_turns_rotated_XB)));
            collectingPlasmaEnd.setKnjktStateSwitchingTimes(Float.valueOf(KNJKT_state_switching_times));
            collectingPlasmaEnd.setKnjktStateSwitchingTimes(Float.valueOf(KNJKT_state_switching_times));
            collectingPlasmaEnd.setTimeKnjktStateSwitchingTimes(new Date(Long.valueOf(time_KNJKT_state_switching_times)));
            collectingPlasmaEnd.setHtStateSwitchingTimes(Integer.valueOf(HT_state_switching_times));
            collectingPlasmaEnd.setTimeHtStateSwitchingTimes(new Date(Long.valueOf(time_HT_state_switching_times)));
            collectingPlasmaEnd.setXykt0StateSwitchingTimes(Integer.valueOf(XYKT0_state_switching_times));
            collectingPlasmaEnd.setTimeXykt0StateSwitchingTimes(new Date(Long.valueOf(time_XYKT0_state_switching_times)));
            collectingPlasmaEnd.setXykt1StateSwitchingTimes(Integer.valueOf(XYKT1_state_switching_times));
            collectingPlasmaEnd.setTimeXykt1StateSwitchingTimes(new Date(Long.valueOf(time_XYKT1_state_switching_times)));
            collectingPlasmaEnd.setXykt2StateSwitchingTimes(Integer.valueOf(XYKT2_state_switching_times));
            collectingPlasmaEnd.setTimeXykt2StateSwitchingTimes(new Date(Long.valueOf(time_XYKT2_state_switching_times)));


            try{
                providerCollection.setCycles(collectingPlasmaEnd.getCycleTime());
                providerCollection.setStartTime(collectingPlasmaEnd.getCollectingPlasmaStartTime());
                providerCollection.setEndTime(collectingPlasmaEnd.getCollectingPlasmaEndTime());
            }catch (Exception e){}
            try{
                long tokensTime = providerCollection.getEndTime().getTime() - providerCollection.getStartTime().getTime();
                providerCollection.setCollTaken(tokensTime);
            }catch (Exception e){}
            try{
                float knj = collectingPlasmaEnd.getKnjPlasmaUsedWeight() == null ? 0:collectingPlasmaEnd.getKnjPlasmaUsedWeight().floatValue();
                if (knj < 5){
                    knj = collectingPlasmaEnd.getTotalTurnsRotatedKnjb();
                }
                providerCollection.setUseKngNum(knj);
            }catch (Exception e){}
            try{
                int trxb = collectingPlasmaEnd.getTotalTurnsRotatedXb().intValue();
                providerCollection.setTotalBloodNum(trxb);
            }catch (Exception e){}
            try{
                int pw = collectingPlasmaEnd.getPlasmaWeight();
                providerCollection.setTotalPlasmaNum(pw);
            }catch (Exception e){}

            if (isUpdate) {
                collectingPlasmaEndMapper.updateById(collectingPlasmaEnd);
            } else {
                collectingPlasmaEndMapper.insert(collectingPlasmaEnd);
            }

        }
    }

    /**
     * 采浆记录-预充
     *
     * @param mlogId
     * @param dbEngine
     */
    private void prechargeInsert(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws SQLException {

        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM precharge");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {
            boolean isUpdate = false;
            Precharge precharge = prechargeMapper.selectById(mlogId);
            if (AdscmBaseUtils.getInstance().isNotEmpty(precharge, null)) {
                isUpdate = true;
            } else {
                precharge = new Precharge();
            }
            precharge.setMlogId(mlogId);
            precharge.setPrechargeStartTime(new Date(Long.valueOf(rs.getString("precharge_start_time"))));
            precharge.setKnjWeightPreprecharge(rs.getFloat("KNJ_weight_preprecharge"));
            precharge.setTimeKnjWeightPreprecharge(new Date(Long.valueOf(rs.getString("time_KNJ_weight_preprecharge"))));
            precharge.setKnjWeightPostprecharge(rs.getFloat("KNJ_weight_postprecharge"));
            precharge.setTimeKnjWeightPostprecharge(new Date(Long.valueOf(rs.getString("time_KNJ_weight_postprecharge"))));
            precharge.setTurnsKnbKnjktCheckedLiquids(rs.getFloat("turns_KNB_KNJKT_checked_liquids"));
            precharge.setTimeTurnsKnbKnjktCheckedLiquids(new Date(Long.valueOf(rs.getString("time_turns_KNB_KNJKT_checked_liquids"))));
            precharge.setTurnsKnbXyktCheckedLiquids(rs.getFloat("turns_KNB_XYKT_checked_liquids"));
            precharge.setTimeTurnsKnbXyktCheckedLiquids(new Date(Long.valueOf(rs.getString("time_turns_KNB_XYKT_checked_liquids"))));
            precharge.setTurnsKnbReverseRotate(rs.getFloat("turns_KNB_reverse_rotate"));
            precharge.setTimeTurnsKnbReverseRotate(new Date(Long.valueOf(rs.getString("time_turns_KNB_reverse_rotate"))));
            precharge.setEigenvalueKnb(rs.getFloat("eigenvalue_KNB"));
            precharge.setTimeEigenvalueKnb(new Date(Long.valueOf(rs.getString("time_eigenvalue_KNB"))));

            if (isUpdate) {
                prechargeMapper.selectById(precharge);
            } else {
                prechargeMapper.insert(precharge);
            }
        }
    }

    /**
     * 采浆记录-自检
     *
     * @param mlogId
     * @param dbEngine
     */
    private void self_checkInsert(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws SQLException {
        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM self_check");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {
            SelfCheck selfCheck = selfCheckMapper.selectById(mlogId);
            boolean isUpdate = false;
            if (AdscmBaseUtils.getInstance().isNotEmpty(selfCheck, null)) {
                isUpdate = true;
            } else {
                selfCheck = new SelfCheck();
            }


            selfCheck.setMlogId(mlogId);
            selfCheck.setKnjktPass(new Date(Long.valueOf(rs.getString("KNJKT_PASS"))));
            selfCheck.setXykt0Pass(new Date(Long.valueOf(rs.getString("XYKT0_PASS"))));
            selfCheck.setXykt1Pass(new Date(Long.valueOf(rs.getString("XYKT1_PASS"))));
            selfCheck.setXykt2Pass(new Date(Long.valueOf(rs.getString("XYKT2_PASS"))));
            selfCheck.setHtzPass(new Date(Long.valueOf(rs.getString("HTZ_PASS"))));
            selfCheck.setGyzPass(new Date(Long.valueOf(rs.getString("GYZ_PASS"))));
            selfCheck.setGywzPass(new Date(Long.valueOf(rs.getString("GYWZ_PASS"))));
            selfCheck.setGkgPass(new Date(Long.valueOf(rs.getString("GKG_PASS"))));
            selfCheck.setLycgqPass(new Date(Long.valueOf(rs.getString("LYCGQ_PASS"))));
            selfCheck.setXjdzcPass(new Date(Long.valueOf(rs.getString("XJDZC_PASS"))));
            selfCheck.setKnjdzcPass(new Date(Long.valueOf(rs.getString("KNJDZC_PASS"))));
            selfCheck.setXdylPass(new Date(Long.valueOf(rs.getString("XDYL_PASS"))));
            selfCheck.setXyfPass(new Date(Long.valueOf(rs.getString("XYF_PASS"))));
            selfCheck.setXjfPass(new Date(Long.valueOf(rs.getString("XJF_PASS"))));
            selfCheck.setYsfPass(new Date(Long.valueOf(rs.getString("YSF_PASS"))));
            selfCheck.setXbPass(new Date(Long.valueOf(rs.getString("XB_PASS"))));
            selfCheck.setKnjbPass(new Date(Long.valueOf(rs.getString("KNJB_PASS"))));
            selfCheck.setLxjPass(new Date(Long.valueOf(rs.getString("LXJ_PASS"))));
            if (isUpdate) {
                selfCheckMapper.updateById(selfCheck);
            } else {
                Integer insert = selfCheckMapper.insert(selfCheck);
                logger.info("自检完成", insert);
            }

        }
    }

    /**
     * 采浆记录-按键记录
     *
     * @param mlogId
     * @param dbEngine
     */
    private void push_buttonInsert(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws Exception {
        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM pushbutton");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {

            PushButton pushButton = new PushButton();
            pushButton.setMlogId(mlogId);
            pushButton.setNo(rs.getInt("no"));
            pushButton.setTime(new Date(Long.valueOf(rs.getString("time"))));
            pushButton.setEvents(rs.getString("events"));
            pushButton.setButtonUi(rs.getString("button_ui"));
            pushButton.setButtonCode(rs.getInt("button_code"));
            Wrapper<PushButton> wrapper = new EntityWrapper<>();
            wrapper.eq("mlogId", pushButton.getMlogId());
            wrapper.eq("no", pushButton.getNo());
            List<PushButton> pushButtons = pushButtonMapper.selectList(wrapper);
            if (pushButtons != null && pushButtons.size() > 0) {
                pushButtonMapper.update(pushButton, wrapper);
            } else {
                pushButtonMapper.insert(pushButton);
            }

        }
    }

    /**
     * 采浆记录-准备耗材
     *
     * @param mlogId
     * @param dbEngine
     */
    private void provision_consumableInsert(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws Exception {
        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM provision_consumable");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {

            ProvisionConsumable provisionConsumable = provisionConsumableMapper.selectById(mlogId);
            boolean isUpdae = false;
            if (AdscmBaseUtils.getInstance().isNotEmpty(provisionConsumable, null)) {
                isUpdae = true;
            } else {
                provisionConsumable = new ProvisionConsumable();
            }
            provisionConsumable.setMlogId(mlogId);
            provisionConsumable.setStartInstallConsumable(new Date(Long.valueOf(rs.getString("start_install_consumable"))));
            provisionConsumable.setEndInstallConsumable(new Date(Long.valueOf(rs.getString("end_install_consumable"))));
            provisionConsumable.setStartAutoTubulature(new Date(Long.valueOf(rs.getString("start_auto_tubulature"))));
            provisionConsumable.setEndAutoTubulature(new Date(Long.valueOf(rs.getString("end_auto_tubulature"))));
            provisionConsumable.setPlasmaBagTare(rs.getInt("plasma_bag_tare"));
            provisionConsumable.setCloseLxjSwitch(new Date(Long.valueOf(rs.getString("close_lxj_switch"))));
            provisionConsumable.setInstallDpm(new Date(Long.valueOf(rs.getString("install_DPM"))));
            provisionConsumable.setInstallPlasmaBag(new Date(Long.valueOf(rs.getString("install_plasma_bag"))));
            provisionConsumable.setTimePlasmaBagTare(new Date(Long.valueOf(rs.getString("time_plasma_bag_tare"))));

            providerCollection.setInstallStartTime(provisionConsumable.getStartInstallConsumable());
            providerCollection.setInstallEndTime(provisionConsumable.getEndInstallConsumable());
            try {
                providerCollection.setInstallTaken(providerCollection.getInstallEndTime().getTime() - providerCollection.getInstallStartTime().getTime());
            } catch (Exception e) {
            }
            providerCollection.setInitWeight(provisionConsumable.getPlasmaBagTare());

            if (isUpdae) {
                provisionConsumableMapper.updateById(provisionConsumable);
            } else {
                provisionConsumableMapper.insert(provisionConsumable);
            }

        }

    }

    /**
     * 采浆记录-机器关闭
     *
     * @param mlogId
     * @param dbEngine
     */
    private void poweroffInsert(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws SQLException {
        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM poweroff");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {
            Poweroff poweroff = poweroffMapper.selectById(mlogId);
            boolean isUpdate = false;
            if (AdscmBaseUtils.getInstance().isNotEmpty(poweroff, null)) {
                isUpdate = true;
            } else {
                poweroff = new Poweroff();
            }
            poweroff.setMlogId(mlogId);
            poweroff.setPoweroffTime(new Date(Long.valueOf(rs.getString("poweroff_time"))));
            if (isUpdate) {
                poweroffMapper.updateById(poweroff);
            } else {
                poweroffMapper.insert(poweroff);
            }


        }
    }

    /**
     * 采浆记录-设置参数
     *
     * @param mlogId
     * @param dbEngine
     */
    private void parameter_settingsInsert(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws SQLException {
        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM parameter_settings");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {
            ParameterSettings parameterSettings = parameterSettingsMapper.selectById(mlogId);
            boolean isUpdate = false;
            if (AdscmBaseUtils.getInstance().isNotEmpty(parameterSettings, null)) {
                isUpdate = true;
            } else {
                parameterSettings = new ParameterSettings();
            }
            parameterSettings.setMlogId(mlogId);
            parameterSettings.setStartSetParametersTime(new Date(Long.valueOf(rs.getString("start_set_parameters_time"))));
            parameterSettings.setSinglewayCollectQuantityMv(rs.getInt("singleway_collect_quantity_MV"));
            parameterSettings.setTotalCollectQuantityMv(rs.getInt("total_collect_quantity_MV"));
            parameterSettings.setCompensatingSalineQuantityMv(rs.getInt("compensating_saline_quantity_MV"));
            parameterSettings.setXdPressureMv(rs.getInt("XD_pressure_MV"));
            parameterSettings.setTotalQuantityDifferenceMv(rs.getInt("total_quantity_difference_MV"));
            parameterSettings.setBloodCollectionSpeed(rs.getInt("blood_collection_speed"));
            parameterSettings.setHsSpeed(rs.getInt("HS_speed"));
            parameterSettings.setEndSetParametersTime(new Date(Long.valueOf(rs.getString("end_set_parameters_time"))));


            if (AdscmBaseUtils.getInstance().isNotEmpty(parameterSettings.getSinglewayCollectQuantityMv(), null)) {
                providerCollection.setSetSingleLayerNum(parameterSettings.getSinglewayCollectQuantityMv());
            }
            if (AdscmBaseUtils.getInstance().isNotEmpty(parameterSettings.getTotalCollectQuantityMv(), null)) {
                providerCollection.setTotalPlasmaNum(parameterSettings.getTotalCollectQuantityMv());
            }
            if (AdscmBaseUtils.getInstance().isNotEmpty(parameterSettings.getTotalQuantityDifferenceMv(), null)) {
                providerCollection.setSetTotalNumCz(parameterSettings.getTotalQuantityDifferenceMv());
            }
            if (AdscmBaseUtils.getInstance().isNotEmpty(parameterSettings.getXdPressureMv(), null)) {
                providerCollection.setSetCuffPressure(parameterSettings.getXdPressureMv());
            }
            if (AdscmBaseUtils.getInstance().isNotEmpty(parameterSettings.getBloodCollectionSpeed(), null)) {
                providerCollection.setSetCollectingSpeed(parameterSettings.getBloodCollectionSpeed());
            }
            if (AdscmBaseUtils.getInstance().isNotEmpty(parameterSettings.getHsSpeed(), null)) {
                providerCollection.setSetHsSpeed(parameterSettings.getHsSpeed());
            }


            if (isUpdate) {
                parameterSettingsMapper.updateById(parameterSettings);
            } else {
                parameterSettingsMapper.insert(parameterSettings);
            }
        }
    }


    /**
     * 采浆记录-互检
     *
     * @param mlogId
     * @param dbEngine
     */
    private void mutual_checkInsert(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws SQLException {
        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM mutual_check");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {
            MutualCheck mutualCheck = mutualCheckMapper.selectById(mlogId);
            boolean isUpdate = false;
            if (AdscmBaseUtils.getInstance().isNotEmpty(mutualCheck, null)) {
                isUpdate = true;
            } else {
                mutualCheck = new MutualCheck();
            }
            mutualCheck.setMlogId(mlogId);
            mutualCheck.setKnjktPass(new Date(Long.valueOf(rs.getString("KNJKT_PASS"))));
            mutualCheck.setXykt0Pass(new Date(Long.valueOf(rs.getString("XYKT0_PASS"))));
            mutualCheck.setXykt1Pass(new Date(Long.valueOf(rs.getString("XYKT1_PASS"))));
            mutualCheck.setXykt2Pass(new Date(Long.valueOf(rs.getString("XYKT2_PASS"))));
            mutualCheck.setGywzPass(new Date(Long.valueOf(rs.getString("GYWZ_PASS"))));
            mutualCheck.setHtzPass(new Date(Long.valueOf(rs.getString("HTZ_PASS"))));
            mutualCheck.setXjdzcPass(new Date(Long.valueOf(rs.getString("XJDZC_PASS"))));
            mutualCheck.setKnjdzcPass(new Date(Long.valueOf(rs.getString("KNJDZC_PASS"))));
            if (isUpdate) {
                mutualCheckMapper.updateById(mutualCheck);
            } else {
                mutualCheckMapper.insert(mutualCheck);
            }
        }

    }

    /**
     * 采浆记录 -加压
     *
     * @param mlogId
     * @param dbEngine
     */
    private void inflatingInsert(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws SQLException {
        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM inflating");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {
            Inflating inflating = inflatingMapper.selectById(mlogId);
            boolean isUpdate = false;
            if (AdscmBaseUtils.getInstance().isNotEmpty(inflating, null)) {
                isUpdate = true;
            } else {
                inflating = new Inflating();
            }
            inflating.setMlogId(mlogId);
            inflating.setStartInflatingTime(new Date(Long.valueOf(rs.getString("start_inflating_time"))));
            inflating.setInflatingParameters(rs.getInt("inflating_parameters"));
            inflating.setTimeInflatingParameters(new Date(Long.valueOf(rs.getString("time_inflating_parameters"))));
            inflating.setAirPumpPressure(rs.getInt("air_pump_pressure"));
            inflating.setTimeAirPumpPressure(new Date(Long.valueOf(rs.getString("time_air_pump_pressure"))));
            if (isUpdate) {
                inflatingMapper.updateById(inflating);
            } else {
                inflatingMapper.insert(inflating);
            }
        }
    }

    /**
     * 浆员登录
     *
     * @param mlogId
     * @param dbEngine
     */
    private void donator_loginInsert(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws SQLException {
        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM donator_login");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {
            DonatorLogin donatorLogin = donatorLoginMapper.selectById(mlogId);
            boolean isUpdate = true;
            if (donatorLogin == null) {
                donatorLogin = new DonatorLogin();
                isUpdate = false;
            }

            donatorLogin.setMlogId(mlogId);
            donatorLogin.setDonatorLoginTime(new Date(Long.valueOf(rs.getString("donator_login_time"))));
            if (isUpdate) {
                donatorLoginMapper.updateById(donatorLogin);
            } else {
                donatorLoginMapper.insert(donatorLogin);
            }

        }
    }

    /**
     * 采浆记录-浆员
     *
     * @param mlogId
     * @param dbEngine
     */
    private void donatorInsert(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws SQLException {
        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM donator");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {
            Donator donator = donatorMapper.selectById(mlogId);
            boolean isUpdate = true;
            if (donator == null) {
                donator = new Donator();
                donator.setMlogId(mlogId);
                isUpdate = false;
            }
            donator.setName(rs.getString("name"));
            donator.setId(rs.getInt("id"));
            donator.setSex(rs.getString("sex"));
            donator.setAge(rs.getInt("age"));
            donator.setAddress(rs.getString("address"));
            donator.setPhotoPath(rs.getString("photo_path"));
            donator.setDonatingAge(rs.getInt("donating_age"));
            donator.setVesselType(rs.getInt("vessel_type"));
            donator.setSecondPuncture(rs.getInt("second_puncture"));
            donator.setRegcode(rs.getString("regcode"));

            //二针穿刺
            Integer secondPuncture = donator.getSecondPuncture();
            if (secondPuncture != null && secondPuncture > 0){
                providerCollection.setSecondPuncture(true);
            }else{
                providerCollection.setSecondPuncture(false);
            }

            if (isUpdate) {
                donatorMapper.updateById(donator);
            } else {
                donatorMapper.insert(donator);
            }
        }
    }

    /**
     * 采浆记录-耗材异常
     *
     * @param mlogId
     * @param dbEngine
     */
    private void consumable_exceptionInsert(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws SQLException {
        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM consumable_exception");
        ResultSet rs = statement.executeQuery();
        while (rs.next()) {
            ConsumableException consumableException = new ConsumableException();
            consumableException.setMlogid(mlogId);
            consumableException.setNo(rs.getInt("no"));

            boolean isUpdate = false;
            consumableException = consumableExceptionMapper.selectOne(consumableException);
            if (consumableException != null) {
                isUpdate = true;
            } else {
                consumableException = new ConsumableException();
                consumableException.setMlogid(mlogId);
                consumableException.setNo(rs.getInt("no"));
            }
            consumableException.setFloor(rs.getInt("floor"));
            consumableException.setExtPara(rs.getInt("ext_para"));
            consumableException.setExtTime(new Date(Long.valueOf(rs.getString("ext_time"))));
            consumableException.setExtRecoverTime(new Date(Long.valueOf(rs.getString("ext_recover_time"))));
            consumableException.setParts(rs.getInt("parts"));
            consumableException.setComponent(rs.getInt("component"));
            consumableException.setExtType(rs.getInt("ext_type"));
            consumableException.setExtMsg(rs.getString("ext_msg"));
            consumableException.setExtLevel(rs.getInt("ext_level"));
            if (isUpdate) {
                Wrapper<ConsumableException> wrapper = new EntityWrapper<>();
                wrapper.eq("mlogId", mlogId);
                wrapper.eq("floor", consumableException.getFloor());
                consumableExceptionMapper.update(consumableException, wrapper);
            } else {
                consumableExceptionMapper.insert(consumableException);
            }
        }
    }

    /**
     * 采浆记录-采集环节
     *
     * @param mlogId
     * @param dbEngine
     * @throws SQLException
     */
    private void collecting_plasmaInsert(String mlogId, SqliteDbEngine dbEngine, ProviderCollection providerCollection) throws SQLException {
        PreparedStatement statement = dbEngine.prepareStatement("SELECT * FROM collecting_plasma");
        ResultSet rs = statement.executeQuery();

        double v = 0;
        int c = 0;

        while (rs.next()) {
            CollectingPlasma collectingPlasma = new CollectingPlasma();
            collectingPlasma.setMlogId(mlogId);
            collectingPlasma.setFloor(rs.getInt("floor"));

            boolean isUpdate = false;
            collectingPlasma = collectingPlasmaMapper.selectOne(collectingPlasma);
            if (collectingPlasma != null) {
                isUpdate = true;
            } else {
                collectingPlasma = new CollectingPlasma();
                collectingPlasma.setMlogId(mlogId);
                collectingPlasma.setFloor(rs.getInt("floor"));
            }

            collectingPlasma.setHtNormalValue(rs.getInt("ht_normal_value"));
            collectingPlasma.setStartCollectingPlasmaTime(new Date(Long.valueOf(rs.getString("start_collecting_plasma_time"))));
            collectingPlasma.setDesiredCollectionQuantity(rs.getInt("desired_collection_quantity"));
            collectingPlasma.setTimeDesiredCollectionQuantity(new Date(Long.valueOf(rs.getString("time_desired_collection_quantity"))));
            collectingPlasma.setActualCollectionQuantity(rs.getInt("actual_collection_quantity"));
            collectingPlasma.setTimeActualCollectionQuantity(new Date(Long.valueOf(rs.getString("time_actual_collection_quantity"))));
            collectingPlasma.setHtRedPlasmaValue(rs.getInt("ht_red_plasma_value"));
            collectingPlasma.setHtDetectPlasmaTime(new Date(Long.valueOf(rs.getString("HT_detect_plasma_time"))));
            collectingPlasma.setTurnsXbRotatedHtDetectPlasma(rs.getFloat("turns_XB_rotated_HT_detect_plasma"));
            collectingPlasma.setTimeTurnsXbRotatedHtDetectPlasma(new Date(Long.valueOf(rs.getString("time_turns_XB_rotated_HT_detect_plasma"))));
            collectingPlasma.setHtPlasmaValue(rs.getInt("ht_plasma_value"));
            collectingPlasma.setDzcDetectPlasmaTime(new Date(Long.valueOf(rs.getString("DZC_detect_plasma_time"))));
            collectingPlasma.setTurnsXbRotatedDzcDetectPlasma(rs.getFloat("turns_XB_rotated_DZC_detect_plasma"));
            collectingPlasma.setTimeTurnsXbRotatedDzcDetectPlasma(new Date(Long.valueOf(rs.getString("time_turns_XB_rotated_DZC_detect_plasma"))));
            collectingPlasma.setEigenvalueXb(rs.getFloat("eigenvalue_XB"));
            collectingPlasma.setTimeEigenvalueXb(new Date(Long.valueOf(rs.getString("time_eigenvalue_XB"))));
            collectingPlasma.setEigenvalueKnb(rs.getFloat("eigenvalue_KNB"));
            collectingPlasma.setDonatorHct(rs.getFloat("donator_HCT"));
            collectingPlasma.setTimeDonatorHct(new Date(Long.valueOf(rs.getString("time_donator_HCT"))));
            collectingPlasma.setTurnsXbRotated(rs.getFloat("turns_XB_rotated"));
            collectingPlasma.setTimeTurnsXbRotated(new Date(Long.valueOf(rs.getString("time_turns_XB_rotated"))));
            collectingPlasma.setTurnsKnjbRotated(rs.getFloat("turns_KNJB_rotated"));
            collectingPlasma.setTimeTurnsKnjbRotated(new Date(Long.valueOf(rs.getString("time_turns_KNJB_rotated"))));
            collectingPlasma.setKnjUsedQuantity(rs.getFloat("KNJ_used_quantity"));
            collectingPlasma.setTimeKnjUsedQuantity(new Date(Long.valueOf(rs.getString("time_KNJ_used_quantity"))));
            collectingPlasma.setDczCollectionEndTime(new Date(Long.valueOf(rs.getString("DCZ_collection_end_time"))));
            collectingPlasma.setHtCollectionEndTime(new Date(Long.valueOf(rs.getString("HT_collection_end_time"))));
            collectingPlasma.setKnjTarget(rs.getFloat("knj_target"));
            collectingPlasma.setKnjDiff(rs.getFloat("knj_diff"));
            collectingPlasma.setKnjTheory(rs.getFloat("knj_theory"));
            collectingPlasma.setKnjExecute(rs.getFloat("knj_execute"));

            if (collectingPlasma.getDonatorHct() != null && collectingPlasma.getDonatorHct().doubleValue() != 0d){
                v += collectingPlasma.getDonatorHct();
                c++;
            }

            if (collectingPlasma.getFloor().intValue() == 1) {
                providerCollection.setPunctureEndTime(collectingPlasma.getStartCollectingPlasmaTime());
            }

            if (isUpdate) {
                Wrapper<CollectingPlasma> wrapper = new EntityWrapper<>();
                wrapper.eq("mlogId", mlogId);
                wrapper.eq("floor", collectingPlasma.getFloor());
                collectingPlasmaMapper.update(collectingPlasma, wrapper);
            } else {
                collectingPlasmaMapper.insert(collectingPlasma);
            }
        }

        if (c > 0) {
//            providerCollection.setHct(v / c);
        }
    }

}
